using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MemberLogin : System.Web.UI.Page
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        FormsAuthentication.RedirectFromLoginPage(this.Login1.UserName, true);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Login1_LoginError(object sender, EventArgs e)
    {
        //Display the failure message in a client-side alert box
        ClientScript.RegisterStartupScript(this.GetType(), "LoginError", String.Format("alert('{0}');", Login1.FailureText.Replace("'", "\'")), true);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        String loginUsername = Login1.UserName;
        String loginPassword = Login1.Password;

        if (Membership.ValidateUser(loginUsername, loginPassword))
        {
            e.Authenticated = true;
        }
        else
        {
            e.Authenticated = false;
            Login1.FailureText = "Your username and/or password are invalid.";
        }
    }
}
